<%--
  Created by IntelliJ IDEA.
  User: 步步为莹
  Date: 2019/9/17
  Time: 9:11
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
    Object name=session.getAttribute("username");
    System.out.println(name);
    //未登录，session为空
    if(name==null){
        response.sendRedirect("pages/login.jsp");
    }
    String param = request.getParameter("controller");
    request.setAttribute("controller", param);
%>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/jsp; charset=UTF-8">
    <title>后台管理系统</title>
    <link rel="stylesheet" href="static/css/style.css">
    <link rel="stylesheet" href="static/css/jquery.wysiwyg.old-school.css">
    
    <!-- jQuery AND jQueryUI -->
    <script type="text/javascript" src="static/js/jquery.min.js"></script>
    <script type="text/javascript" src="static/js/jquery-ui.min.js"></script>
    <script type="text/javascript" src="static/js/min.js"></script>
    <script type="text/javascript" src="static/js/main.js"></script>
    <link rel="stylesheet" href="static/css/style2.css">
        <script type="text/javascript" src="static/js/common.js"></script>
</head>

<style type="text/css">
    body {
        padding: 0;
        margin: 0;
        overflow-y: hidden;
    }
    
    .main {
        height: 100%;
        width: 100%;
        position: absolute;
    }
    
    .top {
        width: 100%;
        height: 42px;
        position: absolute;
        top: 0;
        z-index: 102;
    }
    
    .bottom {
        width: 100%;
        height: 100%;
        position: absolute;
        top: 0;
        z-index: 101;
    }
    
    .left {
        width: 14.4%;
        height: 100%;
        clear: both;
        float: left;
        position: absolute;
        top: 0;
    }
    
    .right {
        width: 100%;
        height: 100%;
    }
    li#one>ul{
        display: none;
    }
</style>

<body>
<div class="main">
    <div class="top">
        <div id="head">
            <div class="left">
                <a class="button profile">
                    <img src="static/images/huser.png" alt=""></a> 你好,
                <a>${sessionScope.username}</a>
<%--                <span>当前时间</span><span id="time"></span>--%>
                <span style="margin-left: 40px" onclick="back()">退出</span>
            </div>
        </div>
    </div>
    vehicle_deprecition_procurement.jsp
    <div class="bottom">
        <div class="left">
            <!--      左侧菜单     -->
            <div id="sidebar" style="background: #464646" >
                <ul></ul>
                <ul>
                    <li>
                        <a>基础设置</a>
                        <ul>
                            <li><a href="javascript:;" class="menu"
                                   onclick="getmenuURL(this)">组织机构
                            </a></li>
                            <li><a href="javascript:;" class="menu" onclick="getmenuURL(this)">部门设置
                            </a></li>
                            <li><a href="javascript:;" class="menu"
                                   onclick="getmenuURL(this)">角色设置</a></li>
                            <li><a href="javascript:;" class="menu"
                                   onclick="getmenuURL(this)">数据字典</a></li>
                            <li><a href="javascript:;" class="menu"
                                   onclick="getmenuURL(this)">菜单项</a></li>
                            <li><a href="javascript:;" class="menu" onclick="getmenuURL(this)">参数设置</a></li>
                            <li><a href="javascript:;" class="menu" onclick="getmenuURL(this)">权限设置</a></li>
                        </ul>
                    </li>
                    <li>
                        <a>车辆管理</a>
                        <ul>
                            <li><a href="javascript:;" class="menu" onclick="getmenuURL(this)" >车辆采购
                            </a></li>
                            <li><a href="javascript:;" class="menu" onclick="getmenuURL(this)">车辆报废</a>
                            </li>
                            <li><a href="javascript:;" class="menu" onclick="getmenuURL(this)">车辆折旧</a></li>
                            <li><a href="javascript:;" class="menu"
                                   onclick="getmenuURL(this)">车辆加油记录
                            </a></li>
                            <li><a href="javascript:;" class="menu" onclick="getmenuURL(this)">车辆维修记录</a></li>
                            <li><a href="javascript:;" class="menu" onclick="getmenuURL(this)">车辆薄</a></li>
                            <li><a href="javascript:;" class="menu" onclick="getmenuURL(this)">车辆调整</a></li>
                            <li><a href="javascript:;" class="menu" onclick="getmenuURL(this)">事故记录</a></li>
                            <li><a href="javascript:;" class="menu" onclick="getmenuURL(this)">车辆顺序</a>
                            </li>
                            <li><a href="javascript:;" class="menu" onclick="getmenuURL(this)">折旧车辆购买</a>
                            </li>
                        </ul>
                    </li>
                    
                    <li>
                        <a>员工管理</a>
                        <ul>
                            <!--pages/employee/employeemanage.jsp-->
                            <li><a href="javascript:;"
                                   onclick="getmenuURL(this)">员工信息维护
                            </a></li>
                            <li><a href="javascript:;" class="menu" onclick="getmenuURL(this)">员工角色调整</a></li>
                        </ul>
                    </li>
                    <li>
                        <a>司机管理</a>
                        <ul>
                            <!--href="pages/driver/driving_license.jsp"-->
                            
                            <li><a href="javascript:;" class="menu"
                                   onclick="getmenuURL(this)">驾照管理</a></li>
                            <li><a href="javascript:;" class="menu" onclick="getmenuURL(this)">违章管理</a></li>
                            <li><a href="javascript:;" class="menu" onclick="getmenuURL(this)">费用报销</a></li>
                        </ul>
                    </li>
                    <li>
                        <a>出行管理</a>
                        <ul>
                            <li><a href="javascript:;" class="menu" onclick="getmenuURL(this)">用车申请</a></li>
                            <li><a href="javascript:;" class="menu" onclick="getmenuURL(this)">用车审批</a></li>
                            <li><a href="javascript:;" class="menu" onclick="getmenuURL(this)">用车记录</a></li>
                            <li><a href="javascript:;" class="menu" onclick="getmenuURL(this)">还车记录</a></li>
                        </ul>
                    </li>
                    
                    <li><a>车辆查询</a>
                        <ul>
                            <li><a href="javascript:;" class="menu" onclick="getmenuURL(this)">车辆采购记录</a></li>
                            <li><a href="javascript:;" class="menu" onclick="getmenuURL(this)">车辆报废记录</a></li>
                            <li><a href="javascript:;" class="menu" onclick="getmenuURL(this)">车辆折旧记录</a></li>
                            <li><a href="javascript:;" class="menu" onclick="getmenuURL(this)">车辆加油记录</a></li>
                            <li><a href="javascript:;" class="menu" onclick="getmenuURL(this)">车辆维修记录</a></li>
                            <li><a href="javascript:;" class="menu" onclick="getmenuURL(this)">车辆事故查询</a></li>
                        </ul>
                    </li>
                    <li><a>司机查询</a>
                        <ul>
                            <li><a href="javascript:;" class="menu" onclick="getmenuURL(this)">驾照查询记录</a></li>
                            <li><a href="javascript:;" class="menu" onclick="getmenuURL(this)">违章记录</a></li>
                            <li><a href="javascript:;" class="menu"onclick="getmenuURL(this)">费用报销记录</a></li>
                        </ul>
                    </li>
                    <li><a>出行查询</a>
                        <ul>
                            <li><a href="javascript:;" class="menu" onclick="getmenuURL(this)">出行申请记录</a></li>
                            <li><a href="javascript:;" class="menu" onclick="getmenuURL(this)">出行审批记录</a></li>
                            <li><a href="javascript:;" class="menu" onclick="getmenuURL(this)">用车记录查询</a></li>
                            <li><a href="javascript:;" class="menu" onclick="getmenuURL(this)">还车记录查询</a></li>
                        </ul>
                    </li>
                
                </ul>
            </div>
        </div>
        <div class="right">
            <%--            <iframe src="pages/employee/employeemanage.jsp"--%>
            <%--                    style="width:1360px;height:800px;overflow-scrolling: unset"></iframe>--%>
            <%-- pages/employee/employeemanage.jsp--%>
            <iframe id="iframe" src="pages/primary.jsp" frameborder="2" name="right"
                    style="border:
    solid 2px red;scrolling:no" width="100%"
                    height="100%;">
            
            </iframe>
            <div id="ui-datepicker-div"
                 class="ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all"></div>
        </div>
    </div>
</div>
<script type="text/javascript">
    
    //加载菜单列表
    <%--$.getJSON("<%=request.getContextPath()%>/menuServlet","opr=listMenuOne",getMenus--%>
    <%--);--%>
    <%--function getMenus(result) {--%>
    <%--    $.each(result, function (index, ele) {--%>
    <%--        $("div#sidebar>ul").append("<li class='one'><a name=" + ele.id + " parentmenu=" +--%>
    <%--            (index + 1) +--%>
    <%--            " class='parentMenu'>" + ele.name + "</a></li>");--%>
    
    <%--    });--%>
    <%--    --%>
    <%--    $("a.parentMenu").click(function () {--%>
    <%--        // var index = $(this).attr("name");--%>
    <%--        //查询二级菜单--%>
    <%--        getMenuTwo($(this));--%>
    <%--    }),function () {--%>
    <%--        $(this).find("ul").hide();--%>
    <%--    }--%>
    <%--}--%>
    //加载二级菜单
    
    function getMenuTwo(obj){
        var parentId=$(obj).attr("name");
        $(obj).parent().append("<ul>");
        $.getJSON("<%=request.getContextPath()%>/menuServlet",
            "opr=selectMenuTwo&Id="+parentId,function
            (result) {
            $.each(result,function (index,ele) {
                $(obj).parent().append("<li><a href='javascript:;' onclick='getmenuURL(this)'>"+ele.name+"</a></li>")
            });
            $(obj).append("</ul");
        });
    }
    
    //点击获得URL
    function getmenuURL(obj) {
        var menuName = $(obj).text();
        var $menuURL = $("iframe#iframe");
        $.ajax({
            url: "<%=request.getContextPath()%>/menuServlet",
            data: "opr=selectMenu&menu=" + menuName,
            type: "GET",
            dataType: "json",
            success: function (result) {
                $menuURL.attr("src", result.uRL);
            }
        });
    }
    
   
   


    //
    <!--闭包-->
    <%--(function () {--%>
    <%--    sendAjax(${controller});--%>
    <%--    var path = "http://localhost:80/MIS/",--%>
    <%--        url = path + "controller";--%>
    
    <%--    function sendAjax(controller) {--%>
    <%--        $.get(url, "controller=" + controller, function (result) {--%>
    <%--            if (result.status === "return") {--%>
    <%--                $("iframe#iframe").attr("src", result.url);--%>
    <%--            }--%>
    <%--        }, "json")--%>
    <%--    }--%>
    
    <%--    &lt;%&ndash;$btn.click(sendAjax(${controller}))&ndash;%&gt;--%>
    
    <%--})()--%>
  function back() {
      window.location.href="<%=request.getContextPath()%>/userServlet?opr=back";
  }

//获得当前时间
    function gettime() {
        var time;
        var today= new Date();
        var year=today.getFullYear();
        var month=today.getMonth()+1;
        var day=today.getDate();
        var hours=today.getHours();
        var minute=today.getMinutes();
        var second=today.getSeconds();
        var week=today.getDay();
        time= year+"-"+chektime(month)+"-"+chektime(day)+" "+chektime(hours)+":"+chektime(minute)+":"+chektime(second)+" 星期"+checkWeek(week);
        $time=$("#time");
        $time.text(time);
    }

    //时间格式小于10，前面补0
    function chektime(obj) {
        if(obj<10){
            return '0'+obj;
        }else{
            return obj;
        }
    }
    //显示星期格式
    function checkWeek(obj) {
        var week;
        switch (obj) {
            case 1:
                week='一';
                break;
            case 2:
                week='二';
                break;
            case 3:
                week='三';
                break;
            case 4:
                week='四';
                break;
            case 5:
                week='五';
                break;
            case 6:
                week='六';
                break;
            case 0:
                week='日';
                break;
        }
        return week;
    }
    var times= setInterval("gettime()",1000);

</script>
</body>
</html>